﻿using LJX.SmartPark.Common.ResponseOutput;
using LJX.SmartPark.Domain.Area;
using LJX.SmartPark.Service.Area;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace LJX.SmartPark.WebApi.Controllers.IotInfo
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    [ApiExplorerSettings(GroupName = "IotInfo")]
    public class CarController : ControllerBase
    {
        private readonly ICarService _CarService;
        public CarController(ICarService CarService)
        {
            _CarService = CarService;
        }
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public Task<Response<bool>> PostAddCar(Car input)
        {
            var result = _CarService.CarAdd(input);
            return result;
        }
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpDelete]
        public Task<Response<bool>> DeleteCar(Car input)
        {
            var result = _CarService.CarDelete(input);
            return result;
        }
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPut]
        public Task<Response<bool>> PutUpdateCar(Car input)
        {
            var result = _CarService.CarUpdate(input);

            return result;

        }
        /// <summary>
        /// 显示
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpGet]
        public Response<List<Car>> GetCarAsync()
        {
            var result = _CarService.GetCarAsync();
            return result.Result;
        }
        /// <summary>
        /// 查询
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public Response<Car> GetCarById(Car input)
        {
            var student = _CarService.GetCarData(input);
            return student;
        }
        /// <summary>
        /// 批量删除
        /// </summary>
        /// <param name="ids"></param>
        /// <returns></returns>
        [HttpPost]
        public Task<Response<bool>> CarsDeleteDatas(string[] ids)
        {

            return _CarService.CarDeleteDatas(ids);
        }
    }
}
